$(function() {
	$('#vue_vm_list div').hide();
});

window.onload = function() {
	var staffId = getLoginedUser()? getLoginedUser().staffId: '';
	var staffName = getLoginedUser()? getLoginedUser().staffName: '';
	var printDate = getNowFormatDate().substr(0,10);
	paperRecord_getDayPaperReportForm(staffId, staffName, printDate);
}

function paperRecord_getDayPaperReportForm(staffId, staffName, printDate) {
	if($('#vue_vm_list div').length==0) {return;}
	$('#vue_vm_list div').hide();
	
	find_basic_by_json(path+'/paperRecord/getDayPaperReportForm', {staffId: staffId, printDate: printDate}, 
		onSuccess=function(response) {	
			new Vue({
				el: '#vue_vm_list',
				data: {
					todos: response.data
				},
				methods: {
					getStaffName:function() {
						return staffName;
					},
					getPrintDate:function() {
						return printDate;
					},
					getInvalidSettleNumStr:function(todo) {
						var str = '';
						for(var i=0; i<todo.invalidPaperForm.settlePaperNumers.length; i++) {
							str += (i==0? '': '\n') + todo.invalidPaperForm.settlePaperNumers[i] + ';';
						}
						return str;
					},
					getInvalidPayNumStr:function(todo) {
						var str = '';
						for(var i=0; i<todo.invalidPaperForm.payPaperNumbers.length; i++) {
							str += (i==0? '': '\n') + todo.invalidPaperForm.payPaperNumbers[i] + ';';
						}
						return str;
					},
					getARMoney:function(todo) {
						return (todo.planPaperForm.totalAmount + todo.settlePaperForm.totalAmount - todo.returnPaperForm.totalAmount).toFixed(2);
					},
					getMoneyCN:function(money) {
						if(money<0){
                            return '负'+ moneyToCN(Math.abs(money));
						}else {
                            return moneyToCN(money);
						}
					}
				}
			});
			
			$('#vue_vm_list div').show();
		},
		onEmpty=function(response) {
			new Vue({
				el: '#vue_vm_list',
				data: {
					todos: response.data
				}
			});
			
			$('#vue_vm_list div').show();
		}
	);
}